<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="root">

    </div>
</body>
<script src="../react@17.js"></script>
<script src="../react-dom@17.js"></script>
<script src="../babel.js"></script>
<script type="text/babel">
    class App extends React.Component{
        num = 1
        state = {
            msg:"好好学习"
        }
        render(){
            return (
                <div>
                 <h1>学习是我快乐----{this.num}----{this.state.msg}</h1>    
                 <button onClick={()=>{
                    this.num++;
                    this.state.msg = '天天有喜'
                    console.log(this)
                    // 强制更新视图 不建议使用 浪费性能
                    this.forceUpdate();
                 }}>++</button>
                </div>
            )
        }
    }

    ReactDOM.render(<App/>,document.getElementById("root"))
</script>
</html>